package com.code.leetcode.center50;

import java.util.ArrayList;
import java.util.List;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/27 10:39
 */
public class The118 {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> lists = new ArrayList<>();
        if (numRows < 1) return lists;
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        lists.add(list);
        for (int i = 1; i < numRows; i++) {
            ArrayList<Integer> l1 = new ArrayList<>();
            List<Integer> l2 = lists.get(i - 1);
            l1.add(1);
            for (int j = 1; j < i; j++) {
                l1.add(l2.get(j - 1) + l2.get(j));
            }
            l1.add(1);
            lists.add(l1);
        }
        return lists;
    }

    public static void main(String[] args) {
        The118 the118 = new The118();
        the118.generate(5);
    }
}
